package org.zsen.crawler.util;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;

public class HtmlUnitHelper {

	private HtmlUnitHelper() {
		
	}
	
	public static WebClient getDefaultWebClient(BrowserVersion version)
	{
		WebClient client=new WebClient();
		client.getOptions().setActiveXNative(false);
		client.getOptions().setCssEnabled(false);
		client.getOptions().setJavaScriptEnabled(true);
		client.getOptions().setRedirectEnabled(false);
		client.getOptions().setThrowExceptionOnScriptError(false);
		client.getOptions().setThrowExceptionOnFailingStatusCode(false);
		client.setAjaxController(new NicelyResynchronizingAjaxController());
		client.setJavaScriptTimeout(5000);
		client.getOptions().setTimeout(5000);
		client.getCookieManager().setCookiesEnabled(false);
		return client;
	}

}
